package com.hefei.genericity;

/**
 * @author caizhengjun
 * @date 2020/9/4 3:42 下午
 */
public class GenericTest {

    public static class Generic<T> {
        private T key;

        public Generic(T key) {
            this.key = key;
        }

        public T getKey() {
            return key;
        }
    }

    public static <T> T showKeyName(Generic<T> container) {
        System.out.println("container.getKey() = " + container.getKey());
        return container.getKey();
    }

    public static void main(String[] args) {
        Generic<String> hello = new Generic<>("hello");
        //System.out.println(hello);
        //System.out.println("hello.getKey() = " + hello.getKey());

        String s = showKeyName(hello);
        System.out.println("s = " + s);
    }
}
